<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <title>Title</title>
    <link rel="stylesheet" th:href="@{/css/plugins/layui/css/layui.css}" >
</head>
<body>
    <div th:object="${hostel}" class="layui-form">
        <input type="hidden" id="id" th:field="*{hostelId}">
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">宿舍号</label>
                <div class="layui-input-inline layui-input-wrap">
                    <input type="text" id="hostelName"  th:field="*{hostelName}" class="layui-input">
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">所属年级</label>
                <div class="layui-input-inline layui-input-wrap">
                    <select id="gradeId" name="gradeId" th:with="grades=${@gradeService.list()}">
                        <option value="">请选择</option>
                        <option th:each="g : ${grades}" th:text="${g.gradeName}" th:value="${g.gradeId}"  th:selected="${hostel.grade != null && g.gradeId == hostel.grade.gradeId}"></option>
                    </select>
                </div>
            </div>
        </div>

    </div>
<script th:src="@{/js/jquery.min.js}"></script>
<script th:src="@{/js/plugins/layui/layui.js}"></script>
<script>
    // 异步请求加载部门列表
    layui.use(function (){
        var laydate = layui.laydate;
        laydate.render({
            elem: '#birthday',
            type: 'date'
        });
    })

</script>
</body>
</html>
